package starter.stepdefinitions;

import io.cucumber.java.After;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import net.serenitybdd.annotations.Steps;
import starter.actions.HomepageSteps;

/**
 * @ClassName HomePageStepdefs
 * @Date 2024/8/5 15:32 20
 * @Author Jack Chen
 * @Description serenity-cucumber-page-objects-starter-master
 * @Version 1.0
 */

public class HomePageStepdefs {

    @Steps
    HomepageSteps homepageSteps;

    @Given("shopping website was opened in browser")
    public void shoppingWebsiteWasOpenedInBrowser() {
        homepageSteps.openShoppingHomePage();
    }

    @When("click user login button")
    public void clickUserLoginButton() {
        //homepageSteps.clickOnLogonButton();
    }

    @Then("enter user name {string} in pop window")
    public void enterUserNameInPop(String username) {
        homepageSteps.enterUserNameInPopWindow(username);
    }

    @Then("enter user password {string} in pop window")
    public void enterUserPasswordInPop(String password) {
        homepageSteps.enterPasswordInPopWindow(password);
    }

    @And("click logon button in pop window")
    public void clickLogonButtonInPop() {
        homepageSteps.clickLogonSubmitInPopWindow();
        
    }

    @Then("home page show message {string}")
    public void homePageShowMessage(String arg0) {

    }

    @Given("user have login the system already")
    public void userHaveLoginTheSystemAlready() {
        
    }

    @When("click on the user logout button")
    public void clickOnTheUserLogoutButton() {

    }

    @When("click user personal center link")
    public void clickUserPersonalCenterLink() {
        homepageSteps.clickOnUserCenterLink(); // to open the login window in home page
    }

    @Then("User login window shows")
    public void userLoginWindowShows() {
        homepageSteps.switchToLogonWindowFrame();
    }

    @After
    public void tearDown() {
        homepageSteps.getDriver().quit();
    }
}
